/******************************************************************************
*  author: hnuweiwei@gmail.com
*  version: 1.0
*  file: myStack.cpp
*  date: 2014.05.25
*  description: 栈的头文件定义
*  other: 无
******************************************************************************/

template<typename T>
void MyStack<T>::push(T const& elem)
{
    elems.push_back(elem);
}



template<typename T>
T MyStack<T>::pop()
{
    if(elems.empty())
    {
        throw out_of_range("Stack<>pop :empty stack");
    }
    T temp=elems.back();
    elems.pop_back();
    return temp;
}


template<typename T>
T MyStack<T>::top() const
{
    if(elems.empty())
    {
        throw out_of_range("Stack<>top :empty stack");
    }
    return elems.back();
}
